package com.huichenghe.xinlvsh01.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.huichenghe.xinlvsh01.R;

import java.util.ArrayList;


    /**
     * 显示时间的RecyclerView的适配器
     */
public class MYRecyclerAdapter extends RecyclerView.Adapter<MYRecyclerAdapter.MyHolder>
    {
        private Context mContext;
        private ArrayList<String> timeList;

        public MYRecyclerAdapter(Context mContext, ArrayList<String> data)
        {
            this.mContext = mContext;
            this.timeList = data;
        }


        @Override
        public MyHolder onCreateViewHolder(ViewGroup parent, int viewType)
        {// 在oncreate中加载布局，返回holder
            View v = LayoutInflater.from(mContext).inflate(R.layout.item_for_show_remind_tiem, parent, false);
            return new MyHolder(v);
        }

        @Override
        public void onBindViewHolder(MyHolder holder, int position)
        {
            // 在控件上设置数据
            holder.mTime.setText(timeList.get(position));

        }

        @Override
        public int getItemCount()
        {
            return timeList.size();
        }

        class MyHolder extends RecyclerView.ViewHolder
        {
            TextView mTime;
            public MyHolder(View itemView)
            {
                super(itemView);
                mTime = (TextView)itemView.findViewById(R.id.time_in_item);// 里边只有一个控件
            }
        }
    }
